require 'scrobbler'
require File.dirname(__FILE__) + '/../src/last-lingo'

#show top played music from user :pcalcado

describe "lingo.fm's DSL", "when queried" do
  before do
      @login = 'pcalcado'
  end

  it "should be able to show user" do
    #old way
    user_from_last = Scrobbler::User.new @login
    #new way
    pcalcado =  user @login
    #they're equal, right?
    pcalcado.username.should eql user_from_last.username
  end

  it "should be able to get recent music from a user" do
 
    #old way
    scrobblerUser = Scrobbler::User.new @login
    tracks_from_last = scrobblerUser.recent_tracks  + scrobblerUser.top_tracks 

    #new way
    all_my_music = music by user @login

    all_my_music.size.should eql tracks_from_last.size
  end

  def test_show_top_player_music_for_a_user
    show top played music by user @login
  end

  it "should be able to get only the played music list from user" do
    #old way
    scrobblerUser = Scrobbler::User.new @login
    tracks_from_last = scrobblerUser.top_tracks

    #new way
    played_music = played music by user @login

    played_music.size.should eql tracks_from_last.size
  end

  it "should be able to get the top from a given list" do
    #old way
    scrobblerUser = Scrobbler::User.new @login
    tracks_from_last = scrobblerUser.top_tracks

    #new way
    top_played_music = top played music by user @login

    tracks_from_last.each do |track| 
	    top_played_music.playcount.should >= track.playcount
    end	
  end

end
